package com.aaa.ssm.controller;

import com.aaa.ssm.entity.TScenicTicket;
import com.aaa.ssm.service.TScenicTicketService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/tst")
public class TScenicTicketController extends BaseController{
    @Resource
    private TScenicTicketService tScenicTicketService;

    //分页查询
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<TScenicTicket> page){
        return success(tScenicTicketService.queryPage(page));
    }
    @PostMapping("queryAll")
    public Result queryAll(@RequestBody TScenicTicket tScenicTicket){
        return success(tScenicTicketService.queryAll());
    }
    //根据编号查询
    @PostMapping("queryById")//普通属性传参 不需要加requestbody
    public Result queryById(int id){
        return success(tScenicTicketService.queryById(id));
    }
    //添加
    @PostMapping("add")
    public Result add(@RequestBody TScenicTicket tScenicTicket){
        return success(tScenicTicketService.add(tScenicTicket));
    }
    //更新
    @PostMapping("update")
    public Result update(@RequestBody TScenicTicket tScenicTicket){
        return success(tScenicTicketService.update(tScenicTicket));
    }

    /**
     * 取票
     * @param id
     * @return
     */
    @GetMapping("/ticket/{id}")
    public Result ticket(@PathVariable Integer id){
        return success(tScenicTicketService.queryticket(id));
    }
    /**
     * 单个查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getList(@PathVariable Integer id){
        return success(tScenicTicketService.getTickets(id));
    }
    //删除
    @PostMapping("deleteById/{id}")
    public Result deleteById(@PathVariable("id") int id){
        return success(tScenicTicketService.deleteById(id));
    }
}
